package com.whut.whw.util;

import android.util.Log;

import com.whut.whw.model.BackResult;
import com.zhy.http.okhttp.callback.Callback;

import org.json.JSONObject;

import okhttp3.Response;

/**
 * <pre>
 *  desc:
 *  Created by 忘尘无憾 on 2017/07/06.
 *  version:
 * </pre>
 */
public abstract class BackResultCallback extends Callback<BackResult> {

    @Override
    public BackResult parseNetworkResponse(Response response, int id) throws Exception {
        String str = response.body().string();
        JSONObject object = new JSONObject(str);
        BackResult backResult = new BackResult();
        backResult.setSuccess(object.getBoolean("success"));
        backResult.setMsg(object.getString("msg"));
        backResult.setData(object.getString("data"));
        return backResult;
    }
}
